import 'package:flutter/services.dart';

class Channel {
  static const platform = const MethodChannel("com.sxbcar.flutterapp/android");
  static const EventChannel eventChannel =
      const EventChannel('com.sxbcar.flutterapp/netChanged');

  static showToast(String msg) async {
    try {
      await platform.invokeMethod("showToast", {"msg": msg});
    } on PlatformException catch (e) {
      print(e.toString());
    }
  }

  static Future<bool> isConnection() async {
    bool isConnection;
    try {
      isConnection = await platform.invokeMethod("netConnection");
    } on PlatformException catch (e) {
      print(e);
    }
    return isConnection;
  }

  static Future<String> getAndroidTime() async {
    var time;
    try {
      time = await platform.invokeMethod("getAndroidTime");
    } on PlatformException catch (e) {
      print(e);
    }
    return time;
  }
}
